package flc.ast.utils;

import androidx.room.Dao;
import androidx.room.Delete;
import androidx.room.Insert;
import androidx.room.Query;
import androidx.room.Update;

import java.util.List;

import flc.ast.bean.PracticeTime;

@Dao//对表操作，增删改查
public interface PracticeDao {
    @Insert
    void insertPracticeTime(PracticeTime... practiceTimes);

    @Update
    void updatePracticeTime(PracticeTime... practiceTimes);

    //条件删除
    @Delete
    void deletePracticeTime(PracticeTime... practiceTimes);

    //删除所有
    @Query("DELETE FROM PracticeTime")
    void deleteAllPractice();

    @Query("SELECT * FROM PracticeTime ORDER BY ID DESC")
    List<PracticeTime>getAllPractice();

    @Query("SELECT * FROM PracticeTime WHERE DATE = :date")
    List<PracticeTime> getTodayPracticeTime(long date);

    @Query("SELECT * FROM PracticeTime WHERE DATE >= :startDate AND date <= :endDate")
    List<PracticeTime> getWeekPracticeTime(long startDate, long endDate);

    @Query("SELECT * FROM PracticeTime WHERE DATE >= :startDate AND date < :endDate")
    List<PracticeTime> getMonthPracticeTime(long startDate, long endDate);

}

